// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:'mupp-5gs2863z7cf6873f'
})

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const db = cloud.database()
  const incomment = db.collection('incomment')
  let Msg = await incomment.add({
    data:{
      comment_pr_id : event.comment_detail.comment_pr_id, //评论Id      
	    comment_user_name : event.comment_detail.comment_user_name, //用户昵称      
	    comment_user_avatar : event.comment_detail.comment_user_avatar, //用户头像      
	    comment_text : event.comment_detail.comment_text, //评论内容      
	    comment_time : db.serverDate(), //评论时间      
	    reply_id : event.comment_detail.reply_id, //回复谁的评论的id      
      parent_id : event.comment_detail.parent_id, //评论所属哪个评论id      
      reply_name : event.comment_detail.reply_name //回复评论人的昵称
    }
  })
  console.log(Msg)

  return {
    Msg
  }
}